<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="app">
        <input type="text" v-model = "newobj" @keydown.13= "get">
       <show></show>
        <!-- <ul>
            <li v-for="(obj,index) in obj">
                {{obj}}
                <button @click="geta(index)">删除</button>
            </li>
        </ul> -->
    </div>
    <script src="../js/vue.js"></script>
    <script>
        Vue.component("show",{
            props:[],
            template:`
            <div>
            <ul>
            <li v-for="(obj,index) in obj">
                {{obj}}
                <button @click="geta(index)">删除</button>
            </li>
            </ul>
            </div>`
        })
        const app = new Vue({
            el:"#app",
            data:{
                newobj:"",
                obj:["顶顶顶顶顶顶顶顶顶顶"]
            },
            methods:{
                get(){
                    this.obj.push(this.newobj);
                    this.newobj=""
                },
                geta(index){
                    this.obj.splice(index,1)
                }
            }
        })
    </script>
</body>
</html>